/**
 * 
 */
package com.personal.Visualplan.entity;

import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 * <p> Project name:Visualplan </p>
 * <p> Class name:Plan </p>
 * @author "JiHongru"
 * @version
 * @date 2020年3月2日上午11:01:48
 * @description  计划类与数据库plan表对应
 *
 */

@Entity
@Table(name = "plan")
public class Plan implements Serializable{
	
	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int id;    //数据库id
	
	private Timestamp release_time;    //plan的发布时间
	
	private Timestamp start_time;      //plan开始执行的时间
	
	private Timestamp end_time;        //plan完成的时间
	
	private int status;                //plan的状态，0-刚刚发布，1-开始执行，2-完成
	
	private String content;            //plan的内容
	
	private int duration;              //plan的执行总时长
	
	@OneToOne
	@JoinColumn(name = "userId", referencedColumnName = "id")
	private User user;                 //plan的发布者通过与usert表的id相连接
	
	@OneToOne
	@JoinColumn(name = "tagId", referencedColumnName = "id")
	private Tag tag;				   //plan的标签通过与tag表的id相连接

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return the release_time
	 */
	public Timestamp getRelease_time() {
		return release_time;
	}

	/**
	 * @param release_time the release_time to set
	 */
	public void setRelease_time(Timestamp release_time) {
		this.release_time = release_time;
	}

	/**
	 * @return the start_time
	 */
	public Timestamp getStart_time() {
		return start_time;
	}

	/**
	 * @param start_time the start_time to set
	 */
	public void setStart_time(Timestamp start_time) {
		this.start_time = start_time;
	}

	/**
	 * @return the end_time
	 */
	public Timestamp getEnd_time() {
		return end_time;
	}

	/**
	 * @param end_time the end_time to set
	 */
	public void setEnd_time(Timestamp end_time) {
		this.end_time = end_time;
	}

	/**
	 * @return the status
	 */
	public int getStatus() {
		return status;
	}

	/**
	 * @param status the status to set
	 */
	public void setStatus(int status) {
		this.status = status;
	}

	/**
	 * @return the content
	 */
	public String getContent() {
		return content;
	}

	/**
	 * @param content the content to set
	 */
	public void setContent(String content) {
		this.content = content;
	}

	/**
	 * @return the duration
	 */
	public int getDuration() {
		return duration;
	}

	/**
	 * @param duration the duration to set
	 */
	public void setDuration(int duration) {
		this.duration = duration;
	}

	/**
	 * @return the user
	 */
	public User getUser() {
		return user;
	}

	/**
	 * @param user the user to set
	 */
	public void setUser(User user) {
		this.user = user;
	}

	/**
	 * @return the tag
	 */
	public Tag getTag() {
		return tag;
	}

	/**
	 * @param tag the tag to set
	 */
	public void setTag(Tag tag) {
		this.tag = tag;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((content == null) ? 0 : content.hashCode());
		result = prime * result + duration;
		result = prime * result + ((end_time == null) ? 0 : end_time.hashCode());
		result = prime * result + id;
		result = prime * result + ((release_time == null) ? 0 : release_time.hashCode());
		result = prime * result + ((start_time == null) ? 0 : start_time.hashCode());
		result = prime * result + status;
		result = prime * result + ((tag == null) ? 0 : tag.hashCode());
		result = prime * result + ((user == null) ? 0 : user.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Plan other = (Plan) obj;
		if (content == null) {
			if (other.content != null)
				return false;
		} else if (!content.equals(other.content))
			return false;
		if (duration != other.duration)
			return false;
		if (end_time == null) {
			if (other.end_time != null)
				return false;
		} else if (!end_time.equals(other.end_time))
			return false;
		if (id != other.id)
			return false;
		if (release_time == null) {
			if (other.release_time != null)
				return false;
		} else if (!release_time.equals(other.release_time))
			return false;
		if (start_time == null) {
			if (other.start_time != null)
				return false;
		} else if (!start_time.equals(other.start_time))
			return false;
		if (status != other.status)
			return false;
		if (tag == null) {
			if (other.tag != null)
				return false;
		} else if (!tag.equals(other.tag))
			return false;
		if (user == null) {
			if (other.user != null)
				return false;
		} else if (!user.equals(other.user))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Plan [id=" + id + ", release_time=" + release_time + ", start_time=" + start_time + ", end_time="
				+ end_time + ", status=" + status + ", content=" + content + ", duration=" + duration + ", user=" + user
				+ ", tag=" + tag + "]";
	}
	
}
